package es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions;

import java.sql.Connection;

import es.udc.fbellas.j2ee.util.exceptions.InstanceNotFoundException;
import es.udc.fbellas.j2ee.util.exceptions.InternalErrorException;
import es.udc.fbellas.j2ee.util.sql.TransactionalPlainAction;
import es.udc.emarketapp.emarket.model.orderDetails.dao.SQLOrderDetailsDAO;
import es.udc.emarketapp.emarket.model.orderDetails.dao.SQLOrderDetailsDAOFactory;

public class DeleteOrderAction implements TransactionalPlainAction {

	private Long idOrder;
	private Long idPurchase;

	public DeleteOrderAction(Long idOrder, Long idPurchase) {

		this.idOrder = idOrder;
		this.idPurchase = idPurchase;

	}

	/**
	 * 
	 * @return <code>null</code>
	 */
	public Object execute(Connection connection)
			throws InstanceNotFoundException, InternalErrorException {

		SQLOrderDetailsDAO orderDAO = SQLOrderDetailsDAOFactory.getDAO();

		orderDAO.remove(connection, idOrder, idPurchase);

		return null;

	}

}
